<html>
<head>
    <style type="text/css">
        .outer {
            width: max-content;
        }
        .inner {
            margin-left: 20%;
            margin-right: 20%;
            width: 50%;
            height: 20px;
            background-color: green;
        }
    </style>
</head>
<body>
    <div class="outer">
        <div class="inner">hello world</div>
    </div>
</body>
</html>